x<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>请假申请</title>
</head>
<body>
	<script type="text/javascript">
		$(function() {
			$('#leave_form').form('load','get_leave');
		})
	</script>
	<script type="text/javascript">
		//根据时间计算天数
			function onSelect(d) { 
			  var day=0;
	          var sd = $('#kssj').datebox('getValue').replace(/-/g, '/'), ed = $('#jssj').datebox('getValue').replace(/-/g, '/');  
	          if (sd != '' && ed != '') {  
	              if (sd > ed) {  
	               $.messager.alert('警告','结束时间要大于开始时间','warning');    
	                  } else {  
	                   var totalMS = new Date(ed).getTime() - new Date(sd).getTime();//得到相差的毫秒数  
	                      day = Math.floor(totalMS/1000/24/60/60);//得到相差天数，不满一天不算一天将Math.ceil改为Math.floor  
	                      $("#qjts").numberbox("setValue", day); //所用天数 
	                      }  
	            }  
	          }
	</script>
	<script type="text/javascript">
		$(function(){
			$("#leave_save").linkbutton(
					{
						onClick : function() {
							$("#leave_form").form(
									"submit",
									{
										url : "save_leave",
										onSubmit : function(params) {
											return $(this).form(
													'enableValidation').form(
													'validate');
										},
										success : function(data) {
											$("#leave_form").form("clear");
											//获取选中的面板
											var tab = $('#tt').tabs(
													'getSelected');
											//根据选中的面板获取该面板的索引
											var index = $('#tt').tabs(
													'getTabIndex', tab);
											//根据索引关闭
											if (index != 0) {
												$('#tt').tabs('close', index);
											}
											$.messager.alert("消息",
													data ? "保存成功！" : "保存失败！");
										}
									});
						}
					})
			
		})
	</script>
	<!-- <script type="text/javascript">
		$(document).ready(function(){
				$.ajaxSetup({
					async:false
				});
				$('#leave_form').form('load','get_leave');
				/* alert($("#syts").val());
				alert($("#qjts").val()); */
				if($("#syts").val() != '' && $("#qjts").val() != '' && $("#aaa").val()=='yearleave') {
					/* alert($("#qjts").val()); */
					if($("#qjts").val() > $("#syts").val()){
						$.messager.alert('警告','年假剩余天数不足，请重新选择','warning');
					}
				}
				/* if($("#aaa").val()=="yearleave") {
				
				var syts = $("#syts").val();
				var qjts = $("#qjts").val();
				alert($("#syts").val());
					if(qjts>syts){
						
					}
				} */
			});
	</script> -->
	<div class="easyui-layout" fit="true">
		<div data-options="region:'center'" align="center" style="border: none;">
			<form id="leave_form" method="post">
				<table class="table" style="margin: 10px; width: 70%" border="0"
					cellpadding="0" cellspacing="0">
					<thead>
						<tr align="center">
							<th colspan="5" style="font-size: 17px">请假申请单</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>
								<input name="empName" class="easyui-textbox"
									style="width: 30%;" label="申请人：" editable="false" >
								<input name="leaveUptime" id="ss" class="easyui-datebox"
									style="width: 30%;" label="申请时间：" readonly="readonly"></input>
								<input name="deptName" class="easyui-textbox" style="width: 30%;"
									label="部门：" editable="false">
								<input name="deptId" type="hidden">
								<input name="empId" type="hidden">
								
							</td>
						</tr>
						<tr>
							<td>
								<input name="positionName" class="easyui-textbox"
									style="width: 30%;" label="职位：" editable="false"> 
								<input name="positionId" type="hidden">
								<input name="leaveStarttime" label="开始时间：" class="easyui-datebox"
									required style="width: 30%;" editable="false" id="kssj"
									data-options="onChange:onSelect"> 
								<input name="leaveEndtime" label="结束时间：" class="easyui-datebox"
									required style="width: 30%;" editable="false" id="jssj"
									data-options="onChange:onSelect">
							</td>
						</tr>
						<tr>
							<td>
								<select name="leaveType" class="easyui-combobox" style="width: 40%;" 
									label="请假类型：" labelWidth='150px' labelAlign='right' editable="false" id="aaa">
									<option value="workleave">事假</option>
									<option value="sickleave">病假</option>
									<option value="offleave">调休</option>
									<option value="marryleave">婚假</option>
									<option value="maternityleave">产假</option>
									<option value="yearleave">年假</option>
									<option value="nursingleave">护理假</option>
									<option value="funeralleave">丧假</option>
									<option value="otherleave">其他</option>
								</select>
								<input name="leaveDay" class="easyui-numberbox" style="width: 30%;" label="请假天数：" 
									id="qjts" data-options="onChange:onSelect" readonly="readonly">
							</td>
						</tr>
						<tr>
							<td>
								<input name="leaveExplain" class="easyui-textbox" style="width: 80%;
									height: 100%;" label="请假事由：" multiline="true" labelWidth="120%" required>
							</td>
						</tr>
						<tr>
							<td style="text-align: center;">
								<a id="leave_save" class="easyui-linkbutton"
									data-options="iconCls:'icon-save',text:'暂存'">
								</a>
								<a id="leave_submit" class="easyui-linkbutton"
									data-options="iconCls:'icon-submit',text:'提交'">
								</a>
								<input name="lunchPeople" type="hidden" >
							</td>
						</tr>
					</tbody>
				</table>
			</form>
		</div>
	</div>
	
</body>
</html>